<!-- pages/index/components/feed-list.vue -->
<script setup>
import { onMounted } from 'vue'
import { doctorLikeAPI } from '../../../apis/doctor';

onMounted(() => {
  console.log('mounted...')
})

// 接收组件外部传入的数据
const props = defineProps({
  list: Array,
  
})
console.log(props,111)

// 引入关注医生的组合式函数
import { useDoctorLike } from '@/composables/index.js'
const { onDoctorLike } = useDoctorLike('knowledge')

</script>

<template>
  <view class="feed-list">
    <view class="feed-list-item" v-for="item in props.list" :key="item.id">
      <view class="feed-meta">
        <image class="doctor-avatar" :src="item.creatorAvatar" />
        <view class="doctor-info">
          <text class="name">{{ item.creatorName }}</text>
          <text class="desc">{{ item.creatorHospatalName }} {{ item.creatorDep }} {{ item.creatorTitles }}</text>
        </view>
        <button class="doctor-button" plain @click="onDoctorLike(item)">{{item.likeFlag === 1 ? '已关注' : '+ 关注'}}</button>
      </view>
      <view class="feed-topic">{{ item.topic }}</view>
      <view class="feed-relation"># {{ item.title }}</view>
      <view class="feed-content">
        <view class="text">
          {{ item.content.replace(/<[^>]+>/g, '') }}
        </view>
        <view class="picture">
          <image
			v-for="pictures in item.coverUrl"
            mode="aspectFill"
            class="uni-image"
            :src="pictures"
          />
        </view>
      </view>
      <view class="feed-extra">
        <text>{{ item.collectionNumber }} 收藏</text>
        <text>{{ item.commentNumber }} 评论</text>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.feed-list-item {
  padding: 40rpx 0;
  margin: 0 30rpx;
  border-bottom: 1rpx solid #ededed;

  &:last-child {
    border-bottom: none;
  }
}

.feed-meta {
  display: flex;
  height: 80rpx;
  position: relative;
}

.doctor-avatar {
  width: 80rpx;
  height: 80rpx;
  border-radius: 50%;
}

.doctor-info {
  flex: 1;
  display: flex;
  justify-content: space-evenly;
  flex-direction: column;
  padding-left: 20rpx;

  .name {
    font-size: 28rpx;
    color: #3c3e42;
  }

  .desc {
    font-size: 24rpx;
    color: #c3c3c5;

    @include text-overflow(1);
  }
}

.doctor-button {
  display: flex;
  width: 140rpx;
  height: 56rpx;
  line-height: 56rpx;
  font-size: 24rpx;
  color: #2cb5a5 !important;
  border: 2rpx solid #2cb5a5 !important;
  border-radius: 60rpx;
}

.feed-topic {
  line-height: 1;
  margin: 30rpx 0 24rpx;
  font-size: 32rpx;
  font-weight: 500;
  color: #121826;
}

.feed-relation {
  line-height: 1;
  margin: 24rpx 0 20rpx;
  font-size: 24rpx;
  color: #2cb5a5;
}

.feed-content {
  font-size: 28rpx;
  color: #6f6f6f;
  
  .text {
	  display: -webkit-box;
	  -webkit-line-clamp: 3;
	  -webkit-box-orient: vertical;
	  text-overflow: ellipsis;
	  overflow: hidden;
  }

  .picture {
    display: flex;
    justify-content: space-between;
    padding: 20rpx 0;
  }

  .uni-image {
    width: 212rpx;
    height: 212rpx;
    border-radius: 20rpx;
  }
}

.feed-extra {
  font-size: 24rpx;
  color: #c3c3c5;
}
</style>